package com.zyk.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.zyk.service.ProductService;

import entity.Product;

@RestController
@RefreshScope
public class ProductController {
	@Autowired
	private ProductService productService;
	
	@RequestMapping(value = "/product/add", method = RequestMethod.POST)
	public boolean add(@RequestBody Product product) {
		return productService.add(product);
	}
	@RequestMapping(value = "/product/get/{id}", method = RequestMethod.GET)
	public Product get(@PathVariable("id") Long id) {
		return productService.get(id);
	}
	@RequestMapping(value = "/product/list", method = RequestMethod.GET)
	public List<Product> list() {
		return productService.list();
	}
	@Value("${emp.name}")
	private String name;
	@GetMapping("/hello")
	public String hello() {
		return name;
	}
}
